#ifndef __THREADPOOL_H__
#define __THREADPOOL_H__

#include "TaskQueue.h"
#include <memory>
#include <functional>
#include <vector>

using namespace std;

class Thread;

// Task就是要执行的任务
using Task=function<void()>;

class ThreadPool
{
public:
    ThreadPool(size_t threadNum, size_t quesize);

    ~ThreadPool();

    void start();

    void stop();

    void addTask(Task&& task);

    Task getTask();

private:
    void doTask();
   
private:
    size_t _threadNum;
    vector<unique_ptr<Thread>> _threads;
    size_t _quesize;
    TaskQueue _taskque;
    bool _isExit;
};

#endif 